package com.itheima.payExample;

import lombok.Data;
import lombok.Setter;

@Data
@Setter
public class SilverCard extends  Card{
    private double discount;
    public SilverCard(String cardId, String name, double money, String phone,  double discount){
        super(cardId, name, money, phone);
        this.discount = discount;
    }

    @Override
    public void consume(double money) {
        System.out.println("你的消费金额是"+  money);
        System.out.println("优惠后的金额是" +money *  discount);
        if(getMoney() <  money *  discount){
            System.out.println("余额不足 无法消费。你的余额是"+ getMoney());
            return;
        }
        setMoney(getMoney() - money * discount); // 减去优惠后的金额
    }
}
